<!-- 蓝色登录页面2 -->
<template>
	<view class="total">
		<view class="img-a">
			<view class="header">
				<view class="return" @click="goBack()">
					<image style="width: 30px;height: 30px;margin-top: 10px;" src="/static/return.png" alt="" />
				</view>
			</view>
		</view>
		<view class="login-view">
			<view class="t-login">
				<view class="welcome">
					欢迎登录候鸟养老
				</view>
				<view class="log_style">
					<view class="blue_font">
						设置登录密码
					</view>
					<view class="tishi">
						设置登录密码，可以使用账号密码直接登录
					</view>
				</view>
			</view>
			<view class="forms">
				<form class="cl">
					<view class="t-a">
						<u-input class="codeInput" type="password" placeholder="请输入密码" v-model="password" />
					</view>
					<view class="t-a">
						<u-input class="codeInput" type="password" placeholder="请再次输入密码" v-model="password2"></u-input>
					</view>
					<button class="login_button" @tap="setPassword()">确 定</button>
				</form>
			</view>

		</view>
		<view class="" style="height: 100rpx;">

		</view>
	</view>
</template>
<script>
	import {
		changePassword
	} from '@/utils/api.js'
	export default {
		data() {
			return {
				password: '', //密码,
				password2: '', //确认密码
				phone2:'', //手机号
			};
		},
		onLoad(option) {
			try {
				const value = uni.getStorageSync('phone');
				if (value) {
					console.log(value);
					this.phone2 = value
				}
			} catch (e) {
				// error
			}
		},
		methods: {
			goBack() {
				uni.navigateBack()
			},
			setPassword() {
				if (!(this.password === this.password2)) {
					uni.showToast({
						title: '两次密码输入不一致',
						icon: 'none'
					});
					return
				}
				if (this.password == '') {
					uni.showToast({
						title: '请输入密码',
						icon: 'none'
					});
					return
				}
				let data ={admin_phone:this.phone2,admin_password:this.password2}
				changePassword(data).then((res)=>{
					console.log(res,'+++++++');
					if(res.data.meta.status==200){
						uni.showToast({ title: '设置成功，请牢记您的密码', icon: 'none' });
						setTimeout(()=>{
							uni.redirectTo({
								url:'/pages/login/login2'
							})
						},1000)
					}
					else{
						uni.showToast({ title: res.data.meta.msg, icon: 'none' });
					}
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.total {
		// padding-top: 20px;
		height: 100%;
		background-color: #f6f6f6;
		position: relative;
	}

	.codeInput {
		height: 33px;
		margin-top: 30rpx;
		margin-bottom: 50rpx;
		border: 1px solid #e9e9e9;
		border-radius: 8px;
		background-color: #F6F6F6;
		font-size: 28rpx;
		padding: 0 15px;
	}

	#getCodeButton {
		margin-top: 0px;
		font-size: 5px;
		width: 80px;
		background-color: #2796f2;
		border-color: #2796f2;
		border-radius: 24px;
		height: 28px;
	}

	.txt {
		font-size: 32rpx;
		font-weight: bold;
		color: #333333;
	}

	.img-a {
		width: 100%;
		height: 450rpx;
		padding-top: 20px;
		background-image: url('/static/img/login_img_bgs.png');
		background-repeat: no-repeat;
		background-size: 100%;

		.header {
			height: 50px;
			line-height: 50px;
			font-size: 20px;
			font-weight: 400;
			color: #FFFFFF;
			display: flex;
			justify-content: space-between;
			padding: 0px 20px;

			.return {
				width: 30px;
				line-height: 50px;
				font-size: 5px;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}
	}

	.reg {
		font-size: 28rpx;
		color: #fff;
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 50rpx;
		font-weight: bold;
		background: #f5f6fa;
		color: #000000;
		text-align: center;
		margin-top: 30rpx;
	}

	.login-view {
		background: #FFFFFF;
		border-radius: 5px;
		width: 94%;
		margin: auto;
		top: 0px;
		left: 0;
		right: 0;
		bottom: 0;
		margin-top: -150px;
		padding-bottom: 100rpx;

		.forms {
			padding: 0 40rpx;
			margin-top: -40rpx;

			.login_button {
				margin-top: 20px;
				font-size: 35rpx;
				background: #2796f2;
				color: #fff;
				height: 90rpx;
				width: 250px;
				line-height: 90rpx;
				border-radius: 50rpx;
				font-weight: bold;
			}
		}
	}

	.t-login {
		width: 600rpx;
		padding: 80rpx 40rpx 0 40rpx;
		font-size: 28rpx;

		.welcome {
			color: #242424;
			font-size: 25px;
			font-weight: bolder;
		}

		.log_style {
			margin-top: 25px;
			margin-bottom: 30px;

			.blue_font {
				color: #2796f2;
				font-size: 18px;
				font-family: PingFang SC;
				font-weight: 800;
			}

			.tishi {
				margin-top: 10px;
				margin-bottom: 50px;
				font-size: 12px;
				font-family: PingFang SC;
				font-weight: 500;
				color: #868686;
			}
		}

		.pic {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			.title {
				// margin-top: 0rpx;
				margin-bottom: 60rpx;
				font-size: 32rpx;
				font-weight: bold;
				color: #484848;
			}

			.uplode {
				margin-bottom: 70rpx;
			}
		}
	}

	.t-login button {
		margin-top: 100rpx;
		font-size: 35rpx;
		background: #2796f2;
		color: #fff;
		height: 90rpx;
		width: 200px;
		line-height: 90rpx;
		border-radius: 50rpx;
		font-weight: bold;
	}

	.t-login input {
		height: 90rpx;
		line-height: 90rpx;
		margin-bottom: 16px;
		border: none;
		border-radius: 8rpx;
		background-color: #F6F6F6;
		font-size: 32rpx;
		padding: 0 15px;
	}

	.t-login .t-a {
		position: relative;
	}

	.t-b {
		text-align: left;
		font-size: 42rpx;
		color: #ffffff;
		padding: 130rpx 0 0 70rpx;
		font-weight: bold;
		line-height: 70rpx;
	}

	.t-login .t-c {
		position: absolute;
		right: 22rpx;
		top: 22rpx;
		background: #5677fc;
		color: #fff;
		font-size: 24rpx;
		border-radius: 50rpx;
		height: 50rpx;
		line-height: 50rpx;
		padding: 0 25rpx;
	}

	.t-login .t-d {
		text-align: center;
		color: #999;
		margin: 80rpx 0;
	}

	.t-login .t-e {
		text-align: center;
		width: 250rpx;
		margin: 80rpx auto 0;
	}

	.t-login .t-g {
		float: left;
		width: 50%;
	}

	.t-login .t-e image {
		width: 50rpx;
		height: 50rpx;
	}

	.t-login .t-f {
		text-align: center;
		margin: 150rpx 0 0 0;
		color: #666;
	}

	.t-login .t-f text {
		margin-left: 20rpx;
		color: #aaaaaa;
		font-size: 27rpx;
	}

	.t-login .uni-input-placeholder {
		color: #aeaeae;
	}

	.cl {
		zoom: 1;
		padding: 0 40rpx;
		width: 100%;

		.forger {
			float: right;
			margin-top: -10px;
		}

		.agreen {
			margin-top: 65px;
			display: flex;

			.radios {
				width: 28px;
				height: 20px;
				margin-right: 10px;
			}

			.texts {
				.txts {
					color: #5398F6;
				}
			}

		}
	}

	.cl:after {
		clear: both;
		display: block;
		visibility: hidden;
		height: 0;
		content: '\20';
	}
</style>